package com.goldgov.semantics.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.goldgov.semantics.service.Semantics;
import com.goldgov.semantics.service.SemanticsService;

@RestController
@RequestMapping("/semantics")
public class SemanticsController {
	
	@Autowired
	private SemanticsService semanticsService;

	@PostMapping
	public String addSemantics(Semantics semantics) {
		semanticsService.addSemantics(semantics);
		return "SUCCESS";
	}
	
	@PutMapping
	public String updateSemantics(Semantics semantics) {
		semanticsService.updateSemantics(semantics);
		return "SUCCESS";
	}
	
	@DeleteMapping
	public String deleteSemantics(@RequestParam("ids") String[] ids) {
		semanticsService.deleteSemantics(ids);
		return "SUCCESS";
	}
	
	@GetMapping
	public List<Semantics> listSemantics(@RequestParam("projectID") String projectID){
		return semanticsService.listSemantics(projectID);
	}
}
